package com.wkq.move.module.tv.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.wkq.move.R;
import com.wkq.move.module.tv.widget.CustomJzvdStd;

/**
 * 作者:吴奎庆
 * <p>
 * 时间:2020/6/3
 * <p>
 * 用途:
 */


public class FullActivity extends AppCompatActivity {

    public static void newInstaceFullActivity(Context context, String title, String poster, String videoPath) {
        Intent intent = new Intent(context, FullActivity.class);
        intent.putExtra("title", title);
        intent.putExtra("poster", poster);
        intent.putExtra("videoPath", videoPath);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
        context.startActivity(intent);

    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_full);
        CustomJzvdStd jzvdStd = (CustomJzvdStd) findViewById(R.id.cjs);

        String videoPath = getIntent().getStringExtra("videoPath");
        String title = getIntent().getStringExtra("title");
        String poster = getIntent().getStringExtra("poster");


        jzvdStd.startFullscreenDirectly(this, CustomJzvdStd.class, videoPath, title);
        Glide.with(this).load(poster).into(jzvdStd.posterImageView);
        jzvdStd.posterImageView.setVisibility(View.VISIBLE);



    }

    @Override
    public void onBackPressed() {
        if (CustomJzvdStd.backPress()) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        CustomJzvdStd.releaseAllVideos();
    }
}
